import 'package:flutter/material.dart';
import 'package:flutter/src/foundation/key.dart';
import 'package:flutter/src/widgets/framework.dart';

class StepperDemoState extends StatefulWidget {
  const StepperDemoState({Key? key}) : super(key: key);

  @override
  State<StepperDemoState> createState() => _StepperDemoStateState();
}

class _StepperDemoStateState extends State<StepperDemoState> {
  int _currentStep = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("步骤组件demo"),
      ),
      body: Container(
        padding:EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Theme(
              data: Theme.of(context).copyWith(primaryColor:Colors.black),
              child: Stepper(
                currentStep: _currentStep,
                onStepTapped: (int value){
                  setState(() {
                    _currentStep = value;
                  });
                },
                onStepContinue: (){
                  setState(() {
                    _currentStep < 2 ? _currentStep += 1 :_currentStep = 0;
                  });
                },
                onStepCancel: (){
                  setState(() {
                    _currentStep > 0? _currentStep -= -1 : _currentStep =0;
                  });
                },
                steps: [
                  Step(title: Text("Login"), 
                  content: Text(
                    "Magna exercitation dajkld asdjka jkasdjk;adjk"
                  ),
                  isActive: _currentStep == 0,
                  ),
                  Step(
                      title: Text("Choose Plan"),
                      subtitle: Text("Choose you plan."),
                      content: Text(
                      "Magna exercitation dajkld asdjka jkasdjk;adjk "),
                        isActive: _currentStep == 1),
                    Step(
                        title: Text("Confirm payment"),
                        subtitle: Text("Confirm your payment method."),
                        content: Text(
                            "Magna exercitation dajkld asdjka jkasdjk;adjk "),
                        isActive: _currentStep == 2),
                ]
              )
              
              )
          ],
        ),
      ),
    );
    
  }
}